package org.NooLab.structures.randomgraph;

import java.io.Serializable;
import java.util.ArrayList;




public class WordPosition implements Serializable{

	
	String              wordStr;
	ArrayList<Integer>  positions     = new ArrayList<Integer>();
	ArrayList<Integer>  charPositions = new ArrayList<Integer>();
	
	ArrayList<WordNeighborhood> neighborhoods = new ArrayList<WordNeighborhood> ();
	
    double              meanPosDiffabs = -1.0, // relates to positions on word (entity) level 
    					meanPosDiffrel = -1.0 ,

    					sdPosDiffabs = -1.0,
    					sdPosDiffrel = -1.0  , 

    					relabundance = -1.0,
    					salienyInDoc = -1.0 ,
						salienyCDocs = -1.0 ;
	
    /** the concatenated FingerPrintMatrix */
    ArrayList<Double>   contextFingerprint = new ArrayList<Double>();
    
    /** this matrix has as any rows as the length of the neighborhood is...
     *  we can chain the descriptions for each word (synonyms, types, stats etc...)
     *  each row then would contain info from different methods, but the regions
     *  are completely in sync across rows 
     *  
     *  we have to keep the matrix because dim reduction is much much more effective than
     *  on 1d vectors (factors >>25)
     *  */
    FingerPrintMatrixIntf   fpMatrix;
	long fingerPrintIndex = -1;
	private int statusFlag = 0;
    
    // ------------------------------------------------------------------------
    public WordPosition(){
    }

    public WordPosition(WordPosition inWP){

    	wordStr = inWP.wordStr   ;
    	if (inWP.positions.size()>0){
    		positions.addAll( inWP.positions)   ;
    	}
    	
        meanPosDiffabs = inWP.meanPosDiffabs   ;
        meanPosDiffrel = inWP.meanPosDiffrel   ;
        sdPosDiffabs = inWP.sdPosDiffabs   ;
        sdPosDiffrel = inWP.sdPosDiffrel   ;
        relabundance = inWP.relabundance   ;
    }
    // ------------------------------------------------------------------------    

	public void clear() {

		if (fpMatrix!=null){
			fpMatrix.close();
		}
		
		positions.clear();
		charPositions.clear();
		contextFingerprint.clear();
		
		if (neighborhoods!=null){
			for (int i = 0; i < neighborhoods.size(); i++) {
				neighborhoods.get(i).clear();
			}
		}

	    
	}

	public ArrayList<WordNeighborhood> getNeighborhoods() {
		return neighborhoods;
	}

	public void setNeighborhoods(ArrayList<WordNeighborhood> neighborhoods) {
		this.neighborhoods = neighborhoods;
	}

	public String getWord() {
		return wordStr;
	}

	public void setWord(String word) {
		this.wordStr = word;
	}

	public ArrayList<Integer> getPositions() {
		return positions;
	}

	public void setPositions(ArrayList<Integer> positions) {
		this.positions = positions;
	}
 
	public double getRelabundance() {
		return relabundance;
	}

	public void setRelabundance(double relabundance) {
		this.relabundance = relabundance;
	}

	public String getWordStr() {
		return wordStr;
	}

	public void setWordStr(String wordstr) {
		this.wordStr = wordstr;
	}

	public double getMeanPosDiffabs() {
		return meanPosDiffabs;
	}

	public void setMeanPosDiffabs(double meanposdiffabs) {
		this.meanPosDiffabs = meanposdiffabs;
	}

	public double getMeanPosDiffrel() {
		return meanPosDiffrel;
	}

	public void setMeanPosDiffrel(double meanposdiffrel) {
		this.meanPosDiffrel = meanposdiffrel;
	}

	public double getSdPosDiffabs() {
		return sdPosDiffabs;
	}

	public void setSdPosDiffabs(double sdposdiffabs) {
		this.sdPosDiffabs = sdposdiffabs;
	}

	public double getSdPosDiffrel() {
		return sdPosDiffrel;
	}

	public void setSdPosDiffrel(double sdposdiffrel) {
		this.sdPosDiffrel = sdposdiffrel;
	}

	public ArrayList<Double> getContextFingerprint() {
		return contextFingerprint;
	}

	public void setContextFingerprint(ArrayList<Double> fingerprint) {
		this.contextFingerprint = fingerprint;
	}

	public ArrayList<Integer> getCharPositions() {
		return charPositions;
	}

	public void addDescriptiveMatrix(FingerPrintMatrixIntf fpm) {
		
		fpMatrix = fpm;
	}

	public FingerPrintMatrixIntf getFpMatrix() {
		return fpMatrix;
	}

	public void setFpMatrix(FingerPrintMatrixIntf fpMatrix) {
		this.fpMatrix = fpMatrix;
	}

	public long getFingerPrintIndex() {
		return fingerPrintIndex;
	}

	public void setFingerPrintIndex(Long fpi) {
		this.fingerPrintIndex = fpi;
	}

	public void setCharPositions(ArrayList<Integer> charPositions) {
		this.charPositions = charPositions;
	}

	public double getSalienyInDoc() {
		return salienyInDoc;
	}

	public void setSalienyInDoc(double salienyInDoc) {
		this.salienyInDoc = salienyInDoc;
	}

	public double getSalienyCDocs() {
		return salienyCDocs;
	}

	public void setSalienyCDocs(double salienyCDocs) {
		this.salienyCDocs = salienyCDocs;
	}

	public void setStatus(int statusflag) {
		// 
		statusFlag = statusflag;
	}

	public int getStatusFlag() {
		return statusFlag;
	}

	public void setStatusFlag(int statusFlag) {
		this.statusFlag = statusFlag;
	}
    

}
